package com.ly.mpayment.core.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * CoreHttpSession.java<br/>
 * 所属类别:Session会话 <br/>
 * Date:2013-7-8 下午3:00:15 <br/>
 * Version:1.0 <br/>
 */
public class CoreHttpSession {
	/**
	 * <p>
	 * 获取Session
	 * </P>
	 * @Date 2013-7-8 下午3:00:54
	 * @return
	 */
	public static HttpSession getSession() {
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
				.getRequestAttributes();
		if(attributes != null){
			HttpServletRequest httpServletRequest = attributes.getRequest();
			return httpServletRequest.getSession();
		}
		return null;
	}
	
	public static HttpServletRequest getRequest() {
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
				.getRequestAttributes();
		HttpServletRequest httpServletRequest = attributes.getRequest();
		return httpServletRequest;
	}
	
	
}
